<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>

<s:url action="shopcart" namespace="/ajax" method="loadProductById"
	var="loadProductUrl"></s:url>
<s:url action="shopcart" namespace="/ajax" method="loadProductsByIds"
	var="loadProductsByIdsUrl"></s:url>
<script type="text/javascript">
var loadProductUrl='${loadProductUrl}';
//alert(loadProductUrl)
var loadProductsByIdsUrl='${loadProductsByIdsUrl}'
</script>

<script type="text/javascript"
	src="${pageContext.request.contextPath}/pages/web/shopCart.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/pages/web/products.js"></script>
</head>
<body class="home">
	<!-- 商品列表部分-->
	<!-- 
		if products.size==0
			{}
			else
				{if products.size%cellNumbers==0//整数倍
					{}
				else//非整数倍，不够，则需要填充
					{}
				}	
	 -->
	<!-- #products -->
	<!-- 每行显示数量 -->
	<s:set name='cellNumbers' value='%{4}'></s:set>
	<div id="products"
		style="margin-left: 2px; display: inline; width: 550px; float: left">
		<!-- 产品列表 -->
		<div class="productList">
			<div class="productListArea">
				<!--<div class="productListBox"></div>-->
				<s:if test="%{products.size==0}">
					<div class="productListBox">
						<s:bean name="org.apache.struts2.util.Counter" id="counter">
							<s:param name="first" value="1" />
							<s:param name="last" value="4" />
							<s:iterator>
								<dl class="product">

								</dl>
							</s:iterator>
						</s:bean>
					</div>
				</s:if>
				<s:else>
					<s:if test="%{products.size%#cellNumbers==0}">
						<!--cellNumbers的倍数 -->
						<s:iterator value="products" status="rowstatus">
							<s:if test="#rowstatus.index%#cellNumbers==0">
								<div class="productListBox clearfix">
							</s:if>
							<!-- 此处插入单个product内容 -->
							<dl class="product">
								<dt>
									<img
										src="${pageContext.request.contextPath}/<s:property value="productFile.urlPath"/>"
										width="129px" height="104px" />
								</dt>
								<dd>
									<div style="color: #9E3738; padding: 20px 0 0 0px">
										<strong><s:property value="name" /> </strong><br /> <em><s:property
												value="price" /> </em>/份 <span class="addToCart"> <s:hidden
												name="id"></s:hidden> </span>
									</div>
								</dd>
							</dl>
							<s:elseif test="#rowstatus.index%#cellNumbers==#cellNumbers-1">
			</div>
			<!-- //end productListBox-->
			</s:elseif>
			</s:iterator>
			</s:if>
			<s:else>
				<!--cellNumbers非整数倍 -->
				<s:set name="rowNumber" value="%{products.size/#cellNumbers}"></s:set>
				<s:set name="moreNumber"
					value="%{((products.size/#cellNumbers)+1)*#cellNumbers-products.size}"></s:set>
				<s:iterator value="products" status="rowstatus">
					<!-- rowNumber:<s:property value="#rowNumber"/>
			cellNumbers:<s:property value="#cellNumbers"/>
			rowstatus.index:<s:property value="#rowstatus.index"/> -->
					<s:if test="#rowstatus.index%#cellNumbers==0">
						<div class="productListBox clearfix">
					</s:if>
					<s:if
						test="#rowstatus.index<=(#rowNumber*#cellNumbers)&&#rowNumber!=0">
						<s:if test="#rowstatus.index%#cellNumbers==0">
							<div class="productListBox">
						</s:if>
						<!-- 此处插入单个product内容 -->
						<dl class="product">
							<dt>
								<img
									src="${pageContext.request.contextPath}/<s:property value="productFile.urlPath"/>"
									width="129px" height="104px" />
							</dt>
							<dd>
								<div style="color: #9E3738; padding: 20px 0 0 0px">
									<strong><s:property value="name" /> </strong><br /> <em><s:property
											value="price" /> </em>/份 <span class="addToCart"> <s:hidden
											name="id"></s:hidden> </span>
								</div>
							</dd>
						</dl>
						<s:elseif test="#rowstatus.index%#cellNumbers==#cellNumbers-1">
		</div>
		<!-- //end productListBox-->
		</s:elseif>
		</s:if>
		<s:else>
			<!-- 此处插入单个product内容-->
			<s:if test="%{products.size-1!=#rowstatus.index}">
				<!-- 此处插入单个product内容 -->
				<dl class="product">
					<dt>
						<img
							src="${pageContext.request.contextPath}/<s:property value="productFile.urlPath"/>"
							width="129px" height="104px" />
					</dt>
					<dd>
						<div style="color: #9E3738; padding: 20px 0 0 0px">
							<strong><s:property value="name" /> </strong><br /> <em><s:property
									value="price" /> </em>/份 <span class="addToCart"> <s:hidden
									name="id"></s:hidden> </span>
						</div>
					</dd>
				</dl>
			</s:if>
			<s:else>
				<!--  最后一个product内容，之后需要填补剩余的-->
				<dl class="product">
					<dt>
						<img
							src="${pageContext.request.contextPath}/<s:property value="productFile.urlPath"/>"
							width="129px" height="104px" />
					</dt>
					<dd>
						<div style="color: #9E3738; padding: 20px 0 0 0px">
							<strong><s:property value="name" /> </strong><br /> <em><s:property
									value="price" /> </em>/份 <span class="addToCart"> <s:hidden
									name="id"></s:hidden> </span>
						</div>
					</dd>
				</dl>
				<!--  需要填补的 -->
				<s:bean name="org.apache.struts2.util.Counter" id="counter">
					<s:param name="first" value="1" />
					<s:param name="last" value="#moreNumber" />
					<s:iterator>
						<dl class="product">

						</dl>
					</s:iterator>
				</s:bean>
	</div>
	</s:else>
	<!-- //end productListBox-->
	</s:else>
	</s:iterator>
	</s:else>
	<!-- end struts tag  -->
	</s:else>
	</div>
	<!-- //.productListArea-->
	</div>
	<!-- //.productList-->
	</div>
	<!-- #products -->
</body>

<input type="button" value="查询" onclick="showCookieData()"></input>
<input type="button" value="删除" onclick="deleteCookie()"></input>
<s:a action="shopcart" namespace="/web" method="loadCookie">后台cookie </s:a>
</html>